#ifndef LIB_PAGE_HASH_QUEUE_H
#define LIB_PAGE_HASH_QUEUE_H
#include <stdint.h>
#include "c.h"
#include "postgres.h"
#include "storage/buf_internals.h"
//max Page Num
#define G_QUEUE_LEN 2048
#define PARALLEL_NUM 8
typedef struct lsn_list_t {
	XLogRecPtr lsn;
	XLogRecPtr endlsn;
	struct lsn_list_t *next;
} lsn_list_t;

typedef struct page_head_list_t {
	BufferTag tag;
	uint32_t count;
	lsn_list_t *head;
	lsn_list_t *tail;
} page_head_list_t; 
extern uint32_t  addFileKey(BufferTag* onePage);
extern void cleanMap(void);
extern uint32_t hashMapSize(void);
extern BufferTag* QueuePushPage(void);
extern void SortPageQueue(void);
extern void InitBufferPoolHashMap(void);
extern Size PageHashQueueShmemSize(void);
extern uint32_t AssignLatchPos(void);
extern void OwnFlushLatch(uint32_t pos);
extern void WakeupOneFlushWork(uint32_t pos);
extern void ResetFlushLatch(uint32_t pos);
extern Latch* GetCurrentLatch(uint32_t pos);
extern void ProcFlushBufferToDisk(BufferTag*tag);
extern uint32_t CompletedTaskNum(void);
extern void SignalStartFlushWork(void);
extern int StartPageFlushWorker(void);
extern Size PageHashMapSize(void);
extern void PageHashQueueShmemInit(void);
Size LogindexHashAllShmemSize(void);
void InitLogindexHashBrucket(void);
void pushSlaveReplayQueue(int pageNum);
void CleanLogIndexMain(int argc, char *argv[]);

extern XLogRecPtr *g_redoStartLsn;

#endif
